﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbLayerState : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbLayerState(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbLayerState obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbLayerState()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbLayerState(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public static OdDbObjectId dictionaryId(OdDbDatabase pDb, bool createIfNotFound)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr cPtr = TD_DbPINVOKE.OdDbLayerState_dictionaryId__SWIG_0(OdDbDatabase.getCPtr(pDb), createIfNotFound);
			OdDbObjectId result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbObjectId(cPtr, true));
				result = new OdDbObjectId(cPtr, false);
			}
			else
			{
				result = new OdDbObjectId(cPtr, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbObjectId dictionaryId(OdDbDatabase pDb)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr cPtr = TD_DbPINVOKE.OdDbLayerState_dictionaryId__SWIG_1(OdDbDatabase.getCPtr(pDb));
			OdDbObjectId result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbObjectId(cPtr, true));
				result = new OdDbObjectId(cPtr, false);
			}
			else
			{
				result = new OdDbObjectId(cPtr, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static bool has(OdDbDatabase pDb, string layerStateName)
		{
			bool result = TD_DbPINVOKE.OdDbLayerState_has(OdDbDatabase.getCPtr(pDb), layerStateName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static void save(OdDbDatabase pDb, string layerStateName, int layerStateMask, OdDbObjectId viewportId)
		{
			TD_DbPINVOKE.OdDbLayerState_save__SWIG_0(OdDbDatabase.getCPtr(pDb), layerStateName, layerStateMask, OdDbObjectId.getCPtr(viewportId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static void save(OdDbDatabase pDb, string layerStateName, int layerStateMask)
		{
			TD_DbPINVOKE.OdDbLayerState_save__SWIG_1(OdDbDatabase.getCPtr(pDb), layerStateName, layerStateMask);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static void restore(OdDbDatabase pDb, string layerStateName, int flags, int layerStateMask, OdDbObjectId viewportId)
		{
			TD_DbPINVOKE.OdDbLayerState_restore__SWIG_0(OdDbDatabase.getCPtr(pDb), layerStateName, flags, layerStateMask, OdDbObjectId.getCPtr(viewportId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static void restore(OdDbDatabase pDb, string layerStateName, int flags, int layerStateMask)
		{
			TD_DbPINVOKE.OdDbLayerState_restore__SWIG_1(OdDbDatabase.getCPtr(pDb), layerStateName, flags, layerStateMask);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static void restore(OdDbDatabase pDb, string layerStateName, int flags)
		{
			TD_DbPINVOKE.OdDbLayerState_restore__SWIG_2(OdDbDatabase.getCPtr(pDb), layerStateName, flags);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static void restore(OdDbDatabase pDb, string layerStateName)
		{
			TD_DbPINVOKE.OdDbLayerState_restore__SWIG_3(OdDbDatabase.getCPtr(pDb), layerStateName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static void setMask(OdDbDatabase pDb, string layerStateName, int layerStateMask)
		{
			TD_DbPINVOKE.OdDbLayerState_setMask(OdDbDatabase.getCPtr(pDb), layerStateName, layerStateMask);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static int mask(OdDbDatabase pDb, string layerStateName)
		{
			int result = TD_DbPINVOKE.OdDbLayerState_mask(OdDbDatabase.getCPtr(pDb), layerStateName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static void remove(OdDbDatabase pDb, string layerStateName)
		{
			TD_DbPINVOKE.OdDbLayerState_remove(OdDbDatabase.getCPtr(pDb), layerStateName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static void rename(OdDbDatabase pDb, string oldName, string newName)
		{
			TD_DbPINVOKE.OdDbLayerState_rename(OdDbDatabase.getCPtr(pDb), oldName, newName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static OdDbLayerState.ImportResult importData(OdDbDatabase pDb, OdStreamBuf pStreamBuf, SWIGTYPE_p_OdString pName)
		{
			OdDbLayerState.ImportResult result = (OdDbLayerState.ImportResult)TD_DbPINVOKE.OdDbLayerState_importData__SWIG_0(OdDbDatabase.getCPtr(pDb), OdStreamBuf.getCPtr(pStreamBuf), SWIGTYPE_p_OdString.getCPtr(pName));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbLayerState.ImportResult importData(OdDbDatabase pDb, OdStreamBuf pStreamBuf)
		{
			OdDbLayerState.ImportResult result = (OdDbLayerState.ImportResult)TD_DbPINVOKE.OdDbLayerState_importData__SWIG_1(OdDbDatabase.getCPtr(pDb), OdStreamBuf.getCPtr(pStreamBuf));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static void exportData(OdDbDatabase pDb, string layerStateName, OdStreamBuf pStreamBuf)
		{
			TD_DbPINVOKE.OdDbLayerState_exportData(OdDbDatabase.getCPtr(pDb), layerStateName, OdStreamBuf.getCPtr(pStreamBuf));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static void setDescription(OdDbDatabase pDb, string layerStateName, string description)
		{
			TD_DbPINVOKE.OdDbLayerState_setDescription(OdDbDatabase.getCPtr(pDb), layerStateName, description);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static string description(OdDbDatabase pDb, string layerStateName)
		{
			string result = TD_DbPINVOKE.OdDbLayerState_description(OdDbDatabase.getCPtr(pDb), layerStateName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static bool hasViewportData(OdDbDatabase pDb, string layerStateName)
		{
			bool result = TD_DbPINVOKE.OdDbLayerState_hasViewportData(OdDbDatabase.getCPtr(pDb), layerStateName);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdResult addLayerStateLayers(string sName, OdDbObjectIdArray layerIds)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbLayerState_addLayerStateLayers(sName, OdDbObjectIdArray.getCPtr(layerIds));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdResult removeLayerStateLayers(OdDbDatabase pDb, string sName, OdStringArray layerNames)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbLayerState_removeLayerStateLayers(OdDbDatabase.getCPtr(pDb), sName, OdStringArray.getCPtr(layerNames));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdResult saveGroup(OdDbDatabase pDb, string sName, OdDbObjectIdArray pLayers, int mask, int includedLayersState, int otherLayersState)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbLayerState_saveGroup__SWIG_0(OdDbDatabase.getCPtr(pDb), sName, OdDbObjectIdArray.getCPtr(pLayers), mask, includedLayersState, otherLayersState);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdResult saveGroup(OdDbDatabase pDb, string sName, OdDbObjectIdArray pLayers, int mask, int includedLayersState)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbLayerState_saveGroup__SWIG_1(OdDbDatabase.getCPtr(pDb), sName, OdDbObjectIdArray.getCPtr(pLayers), mask, includedLayersState);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdResult saveGroup(OdDbDatabase pDb, string sName, OdDbObjectIdArray pLayers, int mask)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbLayerState_saveGroup__SWIG_2(OdDbDatabase.getCPtr(pDb), sName, OdDbObjectIdArray.getCPtr(pLayers), mask);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdResult saveGroup(OdDbDatabase pDb, string sName, OdDbObjectIdArray pLayers)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbLayerState_saveGroup__SWIG_3(OdDbDatabase.getCPtr(pDb), sName, OdDbObjectIdArray.getCPtr(pLayers));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbLayerState() : this(TD_DbPINVOKE.new_OdDbLayerState(), true)
		{
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public const int kUndefDoNothing = 0;

		public const int kUndefTurnOff = 1;

		public const int kUndefFreeze = 2;

		public const int kRestoreAsOverrides = 4;

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;

		[Flags]
		public enum Mask : long
		{
			kDefMask = 4294967295L,
			kNone = 0L,
			kOn = 1L,
			kFrozen = 2L,
			kLocked = 4L,
			kPlot = 8L,
			kNewViewport = 16L,
			kColor = 32L,
			kLineType = 64L,
			kLineWeight = 128L,
			kPlotStyle = 256L,
			kCurrentViewport = 512L,
			kTransparency = 1024L,
			kAll = 2047L,
			kHidden = 32768L
		}

		public enum ImportResult
		{
			kImported,
			kAlreadyExists
		}
	}
}
